package org.example

import org.apache.spark.{SparkConf, SparkContext}


object scala02 {

  def main(args: Array[String]): Unit = {
    val inputFile = "/Users/sungengjia/Desktop/test.txt"
    val conf = new SparkConf().setAppName("WordCount").setMaster("local")
    val sc = new SparkContext(conf)
    val textfile = sc.textFile(inputFile)
    println("=====testFile=====")
    val wordCount = textfile.flatMap(line => line.split(" ")).map(word => (word,1)).reduceByKey((a,b) => a+b)
    wordCount.foreach(println)
  }

}
